export class GameRes {
    static readonly PopCommon = "Prefabs/Popup/PopupCommon2.lh";
    static readonly ItemClickPoint = "Prefabs/Game/ItemClickPoint.lh";
    static readonly ItemReasonRadio = "Prefabs/Game/PopSelectReason/ItemReasonRadio.lh";
    static readonly ItemHReasonRadio = "Prefabs/Game/PopSelectReason/ItemHReasonRadio.lh";
    static readonly GameItemImg ="Prefabs/Game/ListImg/ItemImg.lh"
    static readonly ViewExChange = "Prefabs/Shop/ViewExChange.lh";
    static readonly ViewDetail = "Prefabs/Shop/ViewDetail.lh";
    static readonly ViewRecord = "Prefabs/Shop/ViewRecord.lh";
    static readonly Tips = "Prefabs/Shop/Tips.lh";
    static readonly PageBtn="Prefabs/Shop/PageBtn.lh";

    static readonly clickAudio = "resources/Audio/audioClick.mp3";

    static ResAssetList = [
        GameRes.PopCommon,
        GameRes.ItemClickPoint,
        GameRes.ItemReasonRadio,
        GameRes.ItemHReasonRadio,
        GameRes.GameItemImg,
        GameRes.ViewExChange,
        GameRes.ViewDetail,
        GameRes.ViewRecord,
        GameRes.Tips,
        GameRes.PageBtn
    ]
    static dic: any;
    static loadRes(act:Function = undefined) {
        for (let item of GameRes.ResAssetList) {
            this._load(item,act)
        }
    }
    /** 加载资源 */
    static _load(path: string,act:Function = undefined) {
        if (!GameRes.dic) {
            GameRes.dic = {}
            GameRes.dic["length"] = 0;
        }
        if (GameRes.dic[path]) {
            console.log("资源", path, "已加载", GameRes.dic[path]);
            return;
        }
        Laya.loader.load(path).then((res) => {
            //添加预制体到场景中
            GameRes.dic[path] = res;
            GameRes.dic["length"]++;
            console.log("资源", path, "完成载", res, "|", GameRes.dic);
            if(GameRes.dic["length"] == GameRes.ResAssetList.length){
                act?.()
            }
        });
    }
    /** 获取资源 */
    static getResPrefab(path: string) {
        if (GameRes.dic[path]) {
            return GameRes.dic[path];
        }
        return null
    }
}